﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SaleOrder.ascx.cs" Inherits="Components_SaleOrder" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<telerik:RadScriptManager ID="ScriptManager2" runat="server" EnableTheming="True">
</telerik:RadScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <telerik:radformdecorator id="QsfFromDecorator" runat="server" decoratedcontrols="All" enableroundedcorners="false" />
<div class="leftColFull">
   <div class="aroundFull">
        <div class="greenText18">Thông tin người đặt hàng</div>
        <div class="greenLine"></div>
        <div class="yellowLine"></div>
    </div><!---around------>

    <div class="aroundFull">    
        <table class="aroundFull">
            <tr style="width:100%;height:5px;">
                <td style="width:90px;text-align:right;">Điện thoại</td>
                <td style="width:210px;">
                     <asp:RequiredFieldValidator  ID="RequiredtxtPhoneNumber" runat="server" ControlToValidate="txtPhoneNumber" ValidationGroup="g1"
                      ></asp:RequiredFieldValidator>
                   <telerik:RadTextBox  ID="txtPhoneNumber" CssClass="formBox200" Width="100%"   runat="server"/>
                    <asp:HiddenField runat="server" ID="hidCusID"/>
                </td>
                <td style="width:90px;text-align:right;">Địa chỉ</td>
                <td style="width:210px;">
                    <asp:RequiredFieldValidator  ID="RequiredtxtAddress" runat="server" ControlToValidate="txtAddress" ValidationGroup="g1"
                      ></asp:RequiredFieldValidator>
                    <telerik:RadTextBox ID="txtAddress" CssClass="formBox200" Width="100%"    runat="server"/>
                     
                </td>
                <td style="width:90px;text-align:right;">Tỉnh/ Thành</td>
                <td style="width:210px;">
                     <asp:RequiredFieldValidator  ID="RequiredcboProvince" runat="server" ControlToValidate="cboProvince" ValidationGroup="g1"
                       InitialValue="0"></asp:RequiredFieldValidator>
                    <%--<telerik:RadComboBox ID="cboProvince" runat="server" />--%>
                    <asp:DropDownList ID="cboProvince" runat="server" Width="100%"       CssClass="formBoxSelect" OnSelectedIndexChanged="cboProvince_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
                    
                </td>
            </tr>
            <tr style="width:100%;height:5px;">
                <td style="width:90px;text-align:right;">Họ và tên</td>
                <td style="width:210px;">
                     <asp:RequiredFieldValidator  ID="RequiredtxtFullName" runat="server" ControlToValidate="txtFullName" ValidationGroup="g1"
                      ></asp:RequiredFieldValidator>
                    <telerik:RadTextBox ID="txtFullName" CssClass="formBox200"  Width="100%"      runat="server"/>
                   
                </td>
                <td style="width:90px;text-align:right;">Giao hàng lúc</td>
                <td style="width:210px;">
                    <asp:RequiredFieldValidator  ID="RequireddtpReceiptDate" runat="server" ControlToValidate="dtpReceiptDate" ValidationGroup="g1"
                    ></asp:RequiredFieldValidator>
                  <telerik:RadDateTimePicker ID="dtpReceiptDate" enabled="true" runat="server"  Width="100%" >
                    <Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true" ViewSelectorText="x" Skin="Hay" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False">
                    </Calendar>
                    <DateInput ToolTip="Giao hàng lúc" Width="100%"  Enabled="False" cssclass="formBox" DisplayDateFormat="dd/MM/yyyy HH:mm" DateFormat="dd/MM/yyyy HH:mm"></DateInput>
                </telerik:RadDateTimePicker>
                        
                </td>
               <td style="width:90px;text-align:right;">Quận/Huyện</td>
                <td style="width:210px;">
                   <asp:RequiredFieldValidator  ID="RequiredcboDistrict" runat="server" ControlToValidate="cboDistrict" ValidationGroup="g1"
                       InitialValue=""></asp:RequiredFieldValidator>
                    <asp:DropDownList ID="cboDistrict"  Width="100%"      runat="server" CssClass="formBoxSelect"></asp:DropDownList>
                </td>
            </tr>
            
        </table>
                    
    </div><!---around------>
    <div class="aroundFull">
        <div class="greenText18">Giỏ hàng của bạn</div>
        <div class="greenLine"></div>
        <div class="yellowLine"></div>
    </div><!---around--->
    <div class="board">
    <asp:GridView ID="gvProduct" Runat="server" AutoGenerateColumns="false" EmptyDataText="Không có dữ liệu"  ShowHeaderWhenEmpty="true" onrowcommand="grvProduct_RowCommand"
        Width="990px">
        <Columns>
            <asp:BoundField HeaderText="Tên gạo" DataField="ProductName" HeaderStyle-Width="350px" ItemStyle-Width="350px" ></asp:BoundField>
            <asp:TemplateField HeaderText="Trọng lượng (Kg)" HeaderStyle-Width="100px" ItemStyle-Width="100px">
                <ItemTemplate>
                    <telerik:RadNumericTextBox ID="txtQuantity"  Width="100%"   NumberFormat-DecimalDigits="0" MinValue="0" Text ='<%# Eval("Weight") %>' runat="server" CssClass="formBoxBoard"  AutoPostBack="true"   OnTextChanged="txtQuantity_TextChanged"></telerik:RadNumericTextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Giá bán" HeaderStyle-Width="100px" ItemStyle-Width="100px">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblPrice" Text='<%# String.Format("{0:#,#.##}", float.Parse(Eval("Price").ToString() == "" ? "0" : Eval("Price").ToString()))%>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Thành tiền" HeaderStyle-Width="200px" ItemStyle-Width="200px">
                <ItemTemplate>
                    <asp:Label runat="server" Font-Bold="true" ID="lblAmount" Text='<%# String.Format("{0:#,#.##}", float.Parse(Eval("Amount").ToString() == "" ? "0" : Eval("Amount").ToString()))%>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ProductID">
                <ItemStyle CssClass="DisplayNone"/>
                <HeaderStyle CssClass="DisplayNone"/>
            </asp:BoundField>
            <asp:BoundField DataField="IsPromotion">
                <ItemStyle CssClass="DisplayNone"/>
                <HeaderStyle CssClass="DisplayNone"/>
            </asp:BoundField>
            <asp:TemplateField HeaderText="Xóa" HeaderStyle-Width="30px" ItemStyle-Width="30px">
                <ItemTemplate>
                     <asp:ImageButton ID="btnDelete" runat="server"  OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn xóa?')" CommandArgument='<%#Eval("ProductID") %>' CommandName="cmdDelete" ImageUrl="~/Template/Images/xoa.png" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

        <div id="sumTotal" runat="server" class="sum-total" style="width: 200px; float: right; font-weight: bold;font-size:11pt;margin-right:70px;"></div>
         <div style="clear:both"></div>
         <div id="sumTotalTax" runat="server" class="sum-total" style="width: 200px; float: right; font-weight: bold;font-size:11pt;margin-right:70px;"></div>
         <div style="clear:both"></div>
         <div id="divDiscount" runat="server" class="sum-total" style="width: 200px; float: right; font-weight: bold;font-size:11pt;margin-right:70px;"></div>
        <div style="clear:both"></div>
        <div id="sumPayment" runat="server" class="sum-total" style="width: 200px; float: right; font-weight: bold;font-size:11pt;margin-right:70px;"> </div>

       <div id="sumWeight" runat="server" class="sum-weight" style="display:none;"></div>
       <div id="DivAccumulateAmount" runat="server" style="display:none;"></div>
       <div id="DivSumPayment" runat="server" style="display:none;"></div>
       <div id="DivConvertedAmount" runat="server" style="display:none;"></div>
       <div id="DivDiscountAmount" runat="server" style="display:none;"></div>
       <div id="DivDiscountPromotionID" runat="server" style="display:none;"></div>
       <div id="DivDiscountPromotionDetailID" runat="server" style="display:none;"></div>
    <div style="text-align:center">
    <asp:Button ID="btnOrder" runat="server" Text="ĐẶT HÀNG" CssClass="greenBtn" OnClick="btnOrder_Click" ValidationGroup="g1" OnClientClick="fnOnUpdateValidators();"/>
    <asp:Button ID="btnCont" runat="server" Text="tiếp tục mua hàng" CssClass="greenBtn" OnClick="btnCont_Click"/>
    <asp:Button ID="btnDeleteCard" runat="server" Text="xóa hết giỏ hàng" CssClass="greenBtn" OnClick="btnDeleteCard_Click" OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn xóa hết giỏ hàng?');"/>
  
    <%--<input type="button" class="redBtn" value="đặt hàng" />--%>
    </div>
</div><!---board--->
                
<div class="aroundFull">
    <div class="greenText18">Sản phẩm quà tặng</div>
    <div class="greenLine"></div>
    <div class="yellowLine"></div>
</div><!---around--->
                
<div class="board">
    <asp:GridView ID="gvPromotion" Runat="server" AutoGenerateColumns="false" EmptyDataText="Không có dữ liệu"  ShowHeaderWhenEmpty="true"   Width="990px">
        <Columns>
        <asp:TemplateField HeaderText="STT" ItemStyle-HorizontalAlign="Center">
            <ItemTemplate>
                <%# Container.DataItemIndex + 1 %></ItemTemplate>
            <HeaderStyle Width="50px" />
            <ItemStyle HorizontalAlign="Center" />
        </asp:TemplateField>
        <asp:TemplateField  HeaderText="Hình minh họa">
            <ItemTemplate>
                    <asp:Image Width="70px" runat="server" ID="img" ImageUrl='<%# Eval("Image") %>' ></asp:Image>
            </ItemTemplate>
            <HeaderStyle HorizontalAlign="Center" Width="100px"  />
            <ItemStyle HorizontalAlign="Center" Width="100px" />
        </asp:TemplateField>
        <asp:BoundField  ReadOnly="true"  DataField="ProductID">
            <ItemStyle CssClass="DisplayNone"/>
            <HeaderStyle CssClass="DisplayNone"/>
        </asp:BoundField>
        <asp:BoundField  ReadOnly="true"  DataField="PromotionID">
            <ItemStyle CssClass="DisplayNone"/>
            <HeaderStyle CssClass="DisplayNone"/>
        </asp:BoundField>
        <asp:BoundField  ReadOnly="true"  DataField="PromotionDetailID">
            <ItemStyle CssClass="DisplayNone"/>
            <HeaderStyle CssClass="DisplayNone"/>
        </asp:BoundField>
        <asp:BoundField  ReadOnly="true"  DataField="Weight">
            <ItemStyle CssClass="DisplayNone"/>
            <HeaderStyle CssClass="DisplayNone"/>
        </asp:BoundField>
        <asp:BoundField  ReadOnly="true" HeaderText="Tên quà tặng" DataField="ProductName">
             <HeaderStyle HorizontalAlign="Center" Width="300px"  />
            <ItemStyle HorizontalAlign="Center" Width="300px" />
        </asp:BoundField >
        <asp:TemplateField  HeaderText="Loại quà tặng" >
            <ItemTemplate>
                <asp:Label runat="server" ID="lblPromotionPack" Text='<%# Eval("Weight") %>'></asp:Label>
                <asp:Label runat="server" ID="Label1" Text=" (Kg)"></asp:Label>
            </ItemTemplate>
            <HeaderStyle HorizontalAlign="Center" Width="120px"/>
            <ItemStyle HorizontalAlign="Center" Width="120px" />
        </asp:TemplateField>
        <asp:BoundField   HeaderText="Số lượng KM chưa chọn" DataField="PromotionQuantity">
            <HeaderStyle HorizontalAlign="Center" Width="120px"/>
            <ItemStyle HorizontalAlign="Center" Width="120px" />
        </asp:BoundField>
        <asp:TemplateField  HeaderText="Số lượng KM đã chọn">
            <ItemTemplate>
                <telerik:RadNumericTextBox ID="txtQuantitySelect"  Width="100%"  NumberFormat-DecimalDigits="0" MinValue="0" Text ='<%# Eval("PromotionQuantitySelect") %>' runat="server" CssClass="formBoxBoard"  AutoPostBack="true"   OnTextChanged="txtQuantitySelect_TextChanged"></telerik:RadNumericTextBox>
            </ItemTemplate>
            <HeaderStyle HorizontalAlign="Center" Width="120px" />
            <ItemStyle HorizontalAlign="Center" Width="120px" />
        </asp:TemplateField>                     
        </Columns>
    </asp:GridView>
</div><!----board--->

</div>
 </ContentTemplate>
</asp:UpdatePanel>

<div class="progressbar">
    <asp:UpdateProgress ID="up" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div class="bg">
                <div class="progress progress-striped active">
                    <div class="progress-bar" role="progressbar" aria-valuenow="45" aria-valuemin="0"
                        aria-valuemax="100" style="width: 100%">
                        <span class="sr-only">100% Complete</span>
                    </div>
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</div>

<script type="text/javascript">

    function fnOnUpdateValidators() {
        for (var i = 0; i < Page_Validators.length; i++) {
           
            var val = Page_Validators[i];
            var ctrlID = val.controltovalidate;
            if (ctrlID.toString().indexOf('Date') > 0) {
                ctrlID = ctrlID.toString() + "_dateInput";
            }
            var ctrl = document.getElementById(ctrlID);
            var clsName = ctrl.className;
            if (ctrl != null && ctrl.style != null) {
                if (ctrl.value == '' || ctrl.value == '0') {
                    ctrl.className = clsName.replace("Error", "") + "Error";
                }
                else {
                    ctrl.style.backgroundColor = "";
                    ctrl.className = clsName;
                }
            }
        }
    }
</script>